package com.nycreativity.elecreativity.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page
import com.nycreativity.elecreativity.entity.po.File;
import com.nycreativity.elecreativity.mapper.FileMapper;
import com.nycreativity.elecreativity.service.FileService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nycreativity.elecreativity.entity.param.file.FileQueryParam
import com.nycreativity.elecreativity.entity.vo.PageDataVO
import com.nycreativity.elecreativity.entity.vo.file.FileVO
import com.nycreativity.elecreativity.mapper.vomapper.FileVOMapper
import com.nycreativity.elecreativity.util.KtWrapperUtil
import com.nycreativity.elecreativity.util.PageUtil
import org.springframework.stereotype.Service;
import javax.annotation.Resource

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author sxt && ttxxi
 * @since 2021-03-25
 */
@Service
open class FileServiceImpl : ServiceImpl<FileMapper, File>(), FileService {

    @Resource
    lateinit var fileVOMapper: FileVOMapper

    override fun queryFiles(fileQueryParam: FileQueryParam): PageDataVO<FileVO>? {
        val ktQueryWrapper = KtWrapperUtil.getKtQueryWrapper<FileVO, FileQueryParam>(fileQueryParam)
        val result = fileVOMapper.selectPage(
            Page(
                fileQueryParam.currentPage.toLong(),
                fileQueryParam.pageSize.toLong()
            ), ktQueryWrapper
        )
        return PageUtil.convert(result)
    }

}
